﻿// Project: Salient
// http://salient.codeplex.com
// 
// Copyright 2010, Sky Sanders <sky at skysanders.net>
// Dual licensed under the MIT or GPL Version 2 licenses.
// http://salient.codeplex.com/license
// 
// Date: April 24 2010 

#region

using System.Xml.Linq;
using FluentNHibernate.Conventions;
using FluentNHibernate.Conventions.AcceptanceCriteria;
using FluentNHibernate.Conventions.Inspections;
using FluentNHibernate.Conventions.Instances;
using Salient.SqlServer.NHibernate;

#endregion

namespace Salient.SqlServer.FluentNHibernate
{
    public class XDocumentUserTypeConvention : UserTypeConvention<XDocumentUserType>
    {
        public override void Accept(IAcceptanceCriteria<IPropertyInspector> criteria)
        {
            criteria.Expect(x => x.Property.PropertyType == typeof (XDocument));
        }

        public override void Apply(IPropertyInstance instance)
        {
            instance.CustomType(typeof (XDocumentUserType));
        }
    }
}